#!/bin/bash

# this script builds and (re-)installs locally developed R-packages
# 'candlesticks', 'vadb', 'cssupport', 'vola' and 'quantify'

mkdir /tmp/stratlab_packages
cd /tmp/stratlab_packages
# remove packages from current work dir
rm candlesticks_*.tar.gz
rm vadb_*.tar.gz
rm cssupport_*.tar.gz
rm quantify_*.tar.gz
rm vola_*.tar.gz

# build candlesticks package 
R --vanilla CMD build --compact-vignettes --resave-data=best /home/voellenk/stratlab_workdir/R_Pakete/candlesticks/pkg

# build vadb package
R --vanilla CMD build --compact-vignettes --resave-data=best /home/voellenk/stratlab_workdir/stratlab/TOOLS/vadb/pkg

# build cssupport package
R --vanilla CMD build --compact-vignettes --resave-data=best /home/voellenk/stratlab_workdir/stratlab/TOOLS/cssupport/pkg

# build vola package
R --vanilla CMD build --compact-vignettes --resave-data=best /home/voellenk/stratlab_workdir/stratlab/TOOLS/vola/pkg

# Remove and reinstall packages
R --vanilla CMD REMOVE candlesticks
R --vanilla CMD REMOVE vadb
R --vanilla CMD REMOVE cssupport
R --vanilla CMD REMOVE vola
R --vanilla --verbose CMD INSTALL candlesticks_*.tar.gz
R --vanilla --verbose CMD INSTALL vadb_*.tar.gz 
R --vanilla --verbose CMD INSTALL cssupport_*.tar.gz
R --vanilla --verbose CMD INSTALL vola_*.tar.gz
